package com.nettest.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.nettest.action.BaseJsonAction;
import com.nettest.bean.system.StaffCriteriaVo;
import com.nettest.entity.system.Staff;
import com.nettest.service.system.DeptService;
import com.nettest.service.system.StaffService;

@Results({
	@Result(name = "success", location = "/WEB-INF/jsp/staff/staffQuery.jsp") })
@Action("staffManage")
public class StaffManageAction extends BaseJsonAction {

	private static final long serialVersionUID = 6112400682180451884L;
	private static String PERMISSION_ADD = "STAFF_ADD";
	private StaffCriteriaVo criteria;

	private List<Staff> staffInfoList;
	private int totalCount;
	@Autowired
	private StaffService staffService;
	@Autowired
	private DeptService deptService;

	@Action(value = "staffList",results={@Result(name = "success", location = "/WEB-INF/jsp/staff/staffList.jsp")})
	public String staffList()throws Exception {
		totalCount = staffService.totalSize(criteria);
		if(criteria.getPageSize() == 0) {
			criteria.setPageSize(totalCount);
		}
		staffInfoList = staffService.queryByCriteria(criteria);
		return SUCCESS;
	}
	
	public StaffCriteriaVo getCriteria() {
		return criteria;
	}

	public void setCriteria(StaffCriteriaVo criteria) {
		this.criteria = criteria;
	}

	public StaffService getStaffService() {
		return staffService;
	}

	public void setStaffService(StaffService staffService) {
		this.staffService = staffService;
	}

	public List<Staff> getStaffInfoList() {
		return staffInfoList;
	}

	public void setStaffInfoList(List<Staff> staffInfoList) {
		this.staffInfoList = staffInfoList;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public DeptService getDeptService() {
		return deptService;
	}

	public void setDeptService(DeptService deptService) {
		this.deptService = deptService;
	}
}
